package com.flute.icrawler.framework.batch;

public class CrawlerBatch {

	public static void main(String[] args) {
		System.out.println("b".hashCode());
		CrawlerBatch cb = new CrawlerBatch();
		long s = System.currentTimeMillis();

		for (int i = 0; i < 1000000; i++) {
			cb.ELFHash("http://www.163.com", 1000000000);
		}

		System.out.println(System.currentTimeMillis() - s);
	}

	public int ELFHash(String str, int number) {
		int hash = 0;
		long x = 0l;
		char[] array = str.toCharArray();
		for (int i = 0; i < array.length; i++) {
			hash = (hash << 4) + array[i];
			if ((x = (hash & 0xF0000000L)) != 0) {
				hash ^= (x >> 24);
				hash &= ~x;
			}
		}

		int result = (hash & 0x7FFFFFFF) % number;
		return result;
	}
}